package com.wzl.consumer.config.kafkaConfig;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.listener.ConsumerAwareListenerErrorHandler;

/**
 * kafka消费者异常处理器
 *
 * @author weizhongli
 * @since 2022-09-14 16:59
 */
@Configuration
@Slf4j
public class ConsumerErrorHandler {

    // 新建一个异常处理器，用@Bean注入
    @Bean
    public ConsumerAwareListenerErrorHandler consumerAwareErrorHandler() {
        return (message, exception, consumer) -> {
            log.info("啊哈哈哈消费异常了："+message.getPayload());
            return null;
        };
    }

}